import {Card, Row, Col, List, Space, Typography, Tag} from "antd";
import Base from "@/pages/Province/SubjectDetail/components/Base";
import {CaretDownFilled, CaretUpFilled, FileWordOutlined} from "@ant-design/icons";
import {useEffect, useState} from "react";
import {history} from "umi";
import {Detail05Earn, Detail05Intelligent} from "@/services/Province/Dashboard";
import {ProvinceAllUrl} from "@/utils/format";
import {Link} from "@umijs/preset-dumi/lib/theme";

export default (props) => {

  // 智库建设
  const [earn, setearn] = useState(0)

  const urlArr = history.location.pathname.split('/')
  const school = urlArr[urlArr.length - 1]
  const subject = urlArr[urlArr.length - 2]
  const schoolSubject = school + '-' + subject
  const [rankData, setrankData] = useState([])
  const [reload, setReload] = useState(false)
  useEffect(() => {
    Detail05Earn({subject: schoolSubject}).then(res => {
      if (res.status === 0) {
        setearn(res.data)
      }
    })
    Detail05Intelligent({subject: schoolSubject}).then(res => {
      if (res.status === 0) {
        setrankData(res.data)
      }
    })
  }, [reload])

  const detailMap = {
    '国家级产教融合平台数': {
      fill_id: '5_2_2_1',
      url: ProvinceAllUrl(school, subject, '5_2_2_1', '国家级产教融合平台数')
    },
    '省部级产教融合平台数': {
      fill_id: '5_2_2_2',
      url: ProvinceAllUrl(school, subject, '5_2_2_2', '省部级产教融合平台数')
    },
    '咨政研究获国家领导人肯定性批示数': {
      fill_id: '5_2_2_1',
      url: ProvinceAllUrl(school, subject, '5_2_2_1', '咨政研究获国家领导人肯定性批示数')
    },
    '咨政研究获省部级领导人肯定性批示数': {
      fill_id: '5_2_2_2',
      url: ProvinceAllUrl(school, subject, '5_2_2_2', '咨政研究获省部级领导人肯定性批示数')
    },
  }

  return <Base props={props}>
    <Row gutter={[24, 24]}>
      <Col span={24}><Card title="成果转化">
        <p className="good-content-size">2021年1月至今，学科师生向企业或其他机构，通过成果转移转化，专利、软件著 作权转让许可等形式获得的到校资金总额为：<Typography.Text strong>{earn}万元</Typography.Text></p></Card></Col>
      <Col span={24}><Card title="智库建设">
        <List
          grid={{gutter: 16, column: 2}}
          dataSource={rankData}
          renderItem={item => (
            <List.Item>
              <Card title={<span>{item.title} <Link to={detailMap[item.title] ? detailMap[item.title]['url'] : ''}>详情</Link></span>}>
                  <span style={{fontSize: 16}}>
                    <Space align="center">
                      <Typography.Text>数量：</Typography.Text>
                    <Typography.Text strong>{item.number}</Typography.Text>
                      {/*{item.old_number - item.number > 0 && <Tag style={{marginBottom: 5}} color="green"><CaretDownFilled />较去年减少{item.old_number-item.number}个</Tag>}*/}
                      {/*{item.old_number - item.number < 0 && <Tag style={{marginBottom: 5}} color="red"><CaretUpFilled/>较去年增加{item.number-item.old_number}个</Tag>}*/}
                    </Space>
                  </span>
              </Card>
            </List.Item>
          )}
        />
      </Card></Col>
    </Row>
  </Base>
}
